﻿using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using System;

namespace Galaxy.AutoCAD.Databases
{
    public static class CircleTool
    {
        #region 通过圆上任意三点创建圆（定义为Circle的括展函数）
        public static bool CreateCircle(this Circle circle,Point3d pt1,Point3d pt2,Point3d pt3)
        {
            bool result = false;
            Vector3d va = pt1.GetVectorTo(pt2);
            Vector3d vb = pt1.GetVectorTo(pt3);
            if (va.GetAngleTo(vb) == 0 || va.GetAngleTo(vb) == Math.PI)
            {
                result = false;
            }
            else
            {
                CircularArc3d geArc = new CircularArc3d(pt1, pt2, pt3);
                circle.Center = geArc.Center;
                circle.Radius = geArc.Radius;
                result = true;
            }
            return result;
        }
        #endregion
    }
}
